package com.rule.easyrule.config;

import com.rule.easyrule.entity.BizOrder;
import lombok.extern.slf4j.Slf4j;
import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
import org.jeasy.rules.annotation.Rule;

import java.util.Objects;

@Rule(name = "ordinary_order_rule", description = "普通订单类型", priority = 1)
@Slf4j
public class OrdinaryOrderRule {

    @Condition
    public boolean when(@Fact("order") BizOrder order) {
        return Objects.equals(order.getType(), 1);
    }

    @Action
    public void action(@Fact("order") BizOrder order) {
        log.info("这是一个普通订单，商品goods:{}", order.getGoods());
    }
}
